import prettytable


def get_table(fields):
    return prettytable.PrettyTable(fields=fields,caching=False,right_padding=2)

def message_table(fields,rows):
    table=get_table(fields)
    if rows is None:
        table.printt(hrules=0)
        return
    elif len(rows)>1:
        for row in rows:
            table.add_row(row)
    elif len(rows)==1:
        table.add_row(rows[0])
        
    table.printt(hrules=0)

def error_table(errorinfo):
    table=get_table(("error",))
    table.add_row((errorinfo,))
    table.printt(hrules=0)
